// 商店UI
// @author: wangff8@qq.com  @date: 2024-10-13
library ShoppingUI initializer init requires UIInit

    globals

    endglobals

    // 初始化创建数据面板
    private function createUI takes nothing returns nothing
        local integer ui = StringHash("商店UI")
        local integer i
        local integer i2
        local integer i3

        // 底层面板
        set i = 0
        call SaveInteger(UI_HASH, ui, i, DzCreateFrameByTagName("BACKDROP", "name", DzGetGameUI(), "template", 0))
        call DzFrameSetSize( LoadInteger(UI_HASH, ui, i), 0.35, 0.30 )
        call DzFrameSetTexture( LoadInteger(UI_HASH, ui, i), "UI\\Widgets\\ToolTips\\Human\\human-tooltip-background.blp", 0 )
        call DzFrameSetAbsolutePoint( LoadInteger(UI_HASH, ui, i), 4, 0.40, 0.35 )
        call DzFrameShow( LoadInteger(UI_HASH, ui, i), false )

        set i = 1
        call SaveInteger(UI_HASH, ui, i, DzCreateFrameByTagName("TEXT", "name", LoadInteger(UI_HASH, ui, 0), "UI_TEXT_18", 0))
        call DzFrameSetSize( LoadInteger(UI_HASH, ui, i), 0.18, 0.018 )
        call DzFrameSetPoint( LoadInteger(UI_HASH, ui, i), 1, LoadInteger(UI_HASH, ui, 0), 1, 0.0, -0.008 )
        call DzFrameSetText( LoadInteger(UI_HASH, ui, i), "商店" )


    endfunction


    // 鼠标进入准备按钮
    function IE_Ready takes nothing returns nothing
        local integer uid = GetPlayerId(DzGetTriggerUIEventPlayer())
        local integer ui = StringHash("准备UI")
        local integer i = 1
        
        if DzGetTriggerUIEventFrame() == LoadInteger(UI_HASH, ui, i + 200) then
            call DzFrameSetTexture( LoadInteger(UI_HASH, ui, i), "UI\\Widgets\\Console\\Human\\human-console-button-highlight.blp", 0 )
        endif
    endfunction

    // 鼠标离开准备按钮
    function OE_Ready takes nothing returns nothing
        local integer uid = GetPlayerId(DzGetTriggerUIEventPlayer())
        local integer ui = StringHash("准备UI")
        local integer i = 1

        if DzGetTriggerUIEventFrame() == LoadInteger(UI_HASH, ui, i + 200) then
            call DzFrameSetTexture( LoadInteger(UI_HASH, ui, i), "UI\\Widgets\\ToolTips\\Human\\human-tooltip-background.blp", 0 )
        endif
    endfunction

    // 鼠标点击准备按钮
    function CE_Ready takes nothing returns nothing
        local integer uid = GetPlayerId(DzGetTriggerUIEventPlayer())
        local integer ui = StringHash("准备UI")
        local integer i = 1

        if DzGetTriggerUIEventFrame() == LoadInteger(UI_HASH, ui, i + 200) then
            call DzFrameSetText( LoadInteger(UI_HASH, StringHash("准备UI"), 101), "|cff00ff00已准备|r" )
            call DzSyncData( "UI_Feng_SysnData", "aaa" )
        endif
    endfunction

    // 准备UI
    private function createUI2 takes nothing returns nothing
        local integer ui = StringHash("准备UI")
        local integer i
        local integer i2
        local integer i3

        local real msgX
        local real msgY

        // 底层面板
        // set i = 0
        // call SaveInteger(UI_HASH, ui, i, DzCreateFrameByTagName("BACKDROP", "name", DzGetGameUI(), "template", 0))
        // call DzFrameSetSize( LoadInteger(UI_HASH, ui, i), 0.35, 0.30 )
        // call DzFrameSetTexture( LoadInteger(UI_HASH, ui, i), "UI\\Widgets\\ToolTips\\Human\\human-tooltip-background.blp", 0 )
        // call DzFrameSetAbsolutePoint( LoadInteger(UI_HASH, ui, i), 4, 0.40, 0.35 )
        // call DzFrameShow( LoadInteger(UI_HASH, ui, i), true )

        // 准备按钮
        set i = 1
        call SaveInteger(UI_HASH, ui, i, DzCreateFrameByTagName("BACKDROP", "name", DzGetGameUI(), "template", 0))
        call DzFrameSetSize( LoadInteger(UI_HASH, ui, i), 0.08, 0.025 )
        call DzFrameSetTexture( LoadInteger(UI_HASH, ui, i), "UI\\Widgets\\ToolTips\\Human\\human-tooltip-background.blp", 0 )
        call DzFrameSetAbsolutePoint( LoadInteger(UI_HASH, ui, i), 4, 0.8 - 0.08, 0.20 )
        call DzFrameShow( LoadInteger(UI_HASH, ui, i), false )

        set i2 = i + 100
        call SaveInteger(UI_HASH, ui, i2, DzCreateFrameByTagName("TEXT", "name", LoadInteger(UI_HASH, ui, 1), "UI_TEXT_18", 0))
        call DzFrameSetSize( LoadInteger(UI_HASH, ui, i2), 0.08, 0.025 )
        call DzFrameSetPoint( LoadInteger(UI_HASH, ui, i2), 4, LoadInteger(UI_HASH, ui, i), 4, 0.0, 0.0 )
        call DzFrameSetText( LoadInteger(UI_HASH, ui, i2), "准备" )

        set i3 = i + 200
        call SaveInteger(UI_HASH, ui, i3, DzCreateFrameByTagName("BUTTON", "name", LoadInteger(UI_HASH, ui, i), "template", 0))
        call DzFrameSetSize( LoadInteger(UI_HASH, ui, i3), 0.08, 0.025 )
        call DzFrameSetPoint( LoadInteger(UI_HASH, ui, i3), 4, LoadInteger(UI_HASH, ui, i), 4, 0, 0.0 )
        // 点击事件
        call DzFrameSetScript(LoadInteger(UI_HASH, ui, i3), 1, "CE_Ready", false)
        // 鼠标进入事件
        call DzFrameSetScript(LoadInteger(UI_HASH, ui, i3), 2, "IE_Ready", false)
        // 鼠标离开事件
        call DzFrameSetScript(LoadInteger(UI_HASH, ui, i3), 3, "OE_Ready", false)

        set msgX = 0.6
        set msgY = 0.45
        // 准备提示1
        set i = 10
        call SaveInteger(UI_HASH, ui, i, DzCreateFrameByTagName("BACKDROP", "name", LoadInteger(UI_HASH, ui, 1), "template", 0))
        call DzFrameSetSize( LoadInteger(UI_HASH, ui, i), 0.18, 0.018 )
        call DzFrameSetTexture( LoadInteger(UI_HASH, ui, i), "UI\\Widgets\\ToolTips\\Human\\human-tooltip-background.blp", 0 )
        call DzFrameSetAbsolutePoint( LoadInteger(UI_HASH, ui, i), 3, msgX, msgY )
        call DzFrameShow( LoadInteger(UI_HASH, ui, i), true )
        set i2 = i + 100
        call SaveInteger(UI_HASH, ui, i2, DzCreateFrameByTagName("TEXT", "name", LoadInteger(UI_HASH, ui, i), "UI_TEXT_12_LEFT", 0))
        call DzFrameSetSize( LoadInteger(UI_HASH, ui, i2), 0.18, 0.018 )
        call DzFrameSetPoint( LoadInteger(UI_HASH, ui, i2), 3, LoadInteger(UI_HASH, ui, i), 3, 0.0, 0.0 )
        call DzFrameSetText( LoadInteger(UI_HASH, ui, i2), "玩家[酒鬼剑仙少年郎丶][已准备]" )

        // 准备提示2
        set msgY = msgY - 0.018
        set i = 11
        call SaveInteger(UI_HASH, ui, i, DzCreateFrameByTagName("BACKDROP", "name", LoadInteger(UI_HASH, ui, 1), "template", 0))
        call DzFrameSetSize( LoadInteger(UI_HASH, ui, i), 0.18, 0.018 )
        call DzFrameSetTexture( LoadInteger(UI_HASH, ui, i), "UI\\Widgets\\ToolTips\\Human\\human-tooltip-background.blp", 0 )
        call DzFrameSetAbsolutePoint( LoadInteger(UI_HASH, ui, i), 3, msgX, msgY )
        call DzFrameShow( LoadInteger(UI_HASH, ui, i), true )
        set i2 = i + 100
        call SaveInteger(UI_HASH, ui, i2, DzCreateFrameByTagName("TEXT", "name", LoadInteger(UI_HASH, ui, i), "UI_TEXT_12_LEFT", 0))
        call DzFrameSetSize( LoadInteger(UI_HASH, ui, i2), 0.18, 0.018 )
        call DzFrameSetPoint( LoadInteger(UI_HASH, ui, i2), 3, LoadInteger(UI_HASH, ui, i), 3, 0.0, 0.0 )
        call DzFrameSetText( LoadInteger(UI_HASH, ui, i2), "玩家[酒鬼剑仙少年郎丶][已准备]" )

        // 准备提示3
        set msgY = msgY - 0.018
        set i = 12
        call SaveInteger(UI_HASH, ui, i, DzCreateFrameByTagName("BACKDROP", "name", LoadInteger(UI_HASH, ui, 1), "template", 0))
        call DzFrameSetSize( LoadInteger(UI_HASH, ui, i), 0.18, 0.018 )
        call DzFrameSetTexture( LoadInteger(UI_HASH, ui, i), "UI\\Widgets\\ToolTips\\Human\\human-tooltip-background.blp", 0 )
        call DzFrameSetAbsolutePoint( LoadInteger(UI_HASH, ui, i), 3, msgX, msgY )
        call DzFrameShow( LoadInteger(UI_HASH, ui, i), true )
        set i2 = i + 100
        call SaveInteger(UI_HASH, ui, i2, DzCreateFrameByTagName("TEXT", "name", LoadInteger(UI_HASH, ui, i), "UI_TEXT_12_LEFT", 0))
        call DzFrameSetSize( LoadInteger(UI_HASH, ui, i2), 0.18, 0.018 )
        call DzFrameSetPoint( LoadInteger(UI_HASH, ui, i2), 3, LoadInteger(UI_HASH, ui, i), 3, 0.0, 0.0 )
        call DzFrameSetText( LoadInteger(UI_HASH, ui, i2), "玩家[酒鬼剑仙少年郎丶][已准备]" )

        // 准备提示4
        set msgY = msgY - 0.018
        set i = 13
        call SaveInteger(UI_HASH, ui, i, DzCreateFrameByTagName("BACKDROP", "name", LoadInteger(UI_HASH, ui, 1), "template", 0))
        call DzFrameSetSize( LoadInteger(UI_HASH, ui, i), 0.18, 0.018 )
        call DzFrameSetTexture( LoadInteger(UI_HASH, ui, i), "UI\\Widgets\\ToolTips\\Human\\human-tooltip-background.blp", 0 )
        call DzFrameSetAbsolutePoint( LoadInteger(UI_HASH, ui, i), 3, msgX, msgY )
        call DzFrameShow( LoadInteger(UI_HASH, ui, i), true )
        set i2 = i + 100
        call SaveInteger(UI_HASH, ui, i2, DzCreateFrameByTagName("TEXT", "name", LoadInteger(UI_HASH, ui, i), "UI_TEXT_12_LEFT", 0))
        call DzFrameSetSize( LoadInteger(UI_HASH, ui, i2), 0.18, 0.018 )
        call DzFrameSetPoint( LoadInteger(UI_HASH, ui, i2), 3, LoadInteger(UI_HASH, ui, i), 3, 0.0, 0.0 )
        call DzFrameSetText( LoadInteger(UI_HASH, ui, i2), "玩家[酒鬼剑仙少年郎丶][已准备]" )

    endfunction


    private function init takes nothing returns nothing
        local integer ui = StringHash("商店UI")

        call createUI()
        call createUI2()
    endfunction
endlibrary
